package com.asura.ops.sync.sdk.config;

import com.asura.ops.sync.sdk.consumer.ChangeConsumer;
import com.asura.ops.sync.sdk.consumer.DefaultChangeConsumer;
import com.asura.ops.sync.sdk.handle.DefaultProcessCycle;
import com.asura.ops.sync.sdk.handle.DefaultSyncHandler;
import com.asura.ops.sync.sdk.handle.ProcessCycle;
import com.asura.ops.sync.sdk.handle.SyncHandler;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: huyuntao(Mars)
 * @date: 2022/8/10
 * @description: 类的描述
 */
@Configuration
public class SdkConfig {

    @Bean
    @ConditionalOnMissingBean(ChangeConsumer.class)
    public ChangeConsumer changeConsumer() {
        return new DefaultChangeConsumer();
    }

    @Bean
    @ConditionalOnMissingBean(SyncHandler.class)
    public DefaultSyncHandler defaultSyncHandler() {
        DefaultSyncHandler defaultSyncHandler = new DefaultSyncHandler();

        //配置为空
        defaultSyncHandler.configTableEntityClassMap(Maps.newConcurrentMap());
        defaultSyncHandler.configDatasourceList(Lists.newArrayList());

        return defaultSyncHandler;
    }

    @Bean
    @ConditionalOnMissingBean(ProcessCycle.class)
    public DefaultProcessCycle defaultProcessCycle() {
        return new DefaultProcessCycle();
    }
}
